home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / src / pobox / ch_pobox.c next >
Encoding:
C/C++ Source or Header  |  1986-02-01  |  3.5 KB  |  137 lines

  1. #include "util.h"
  2. #include "mmdf.h"
  3.  
  4. /*
  5.  *     MULTI-CHANNEL MEMO DISTRIBUTION FACILITY  (MMDF)
  6.  *     
  7.  *
  8.  *     Copyright (C) 1979,1980,1981  University of Delaware
  9.  *     
  10.  *     Department of Electrical Engineering
  11.  *     University of Delaware
  12.  *     Newark, Delaware  19711
  13.  *
  14.  *     Phone:  (302) 738-1163
  15.  *     
  16.  *     
  17.  *     This program module was developed as part of the University
  18.  *     of Delaware's Multi-Channel Memo Distribution Facility (MMDF).
  19.  *     
  20.  *     Acquisition, use, and distribution of this module and its listings
  21.  *     are subject restricted to the terms of a license agreement.
  22.  *     Documents describing systems using this module must cite its source.
  23.  *
  24.  *     The above statements must be retained with all copies of this
  25.  *     program and may not be removed without the consent of the
  26.  *     University of Delaware.
  27.  *     
  28.  *
  29.  *     version  -1    David H. Crocker    March   1979
  30.  *     version   0    David H. Crocker    April   1980
  31.  *     version  v7    David H. Crocker    May     1981
  32.  *     version   1    David H. Crocker    October 1981
  33.  *
  34.  */
  35. /*                      SEND ON PICKUP REQUEST                          */
  36.  
  37. #include <signal.h>
  38. #include "ch.h"
  39. #include "phs.h"
  40.  
  41. extern LLog *logptr;
  42. extern char po_state;    /* state of processing current msg    */
  43.  
  44. LOCVAR char ibuf[BUFSIZ],         /* input buffer for fd 0              */
  45.         obuf[BUFSIZ];         /* output buffer for fd 1             */
  46.  
  47. /*      MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN MAIN     */
  48.  
  49. main (argc, argv)
  50. int     argc;
  51. char   *argv[];
  52. {
  53.     extern char *dupfpath ();
  54.     int retval;
  55.  
  56.     setbuf (stdin, ibuf);
  57.     setbuf (stdout, obuf);
  58.     mmdf_init (argv[0]);
  59.     siginit ();
  60.     signal (SIGINT, SIG_IGN);      /* always ignore interrupts             */
  61.  
  62.     retval = ch_pobox (argc, argv);
  63.  
  64.     ll_close (logptr);
  65.  
  66.     exit (retval);
  67. }
  68. /* ****************  (ch_) LOCAL MAIL DELIVERY  ********************** */
  69.  
  70. ch_pobox (argc, argv)          /* send to local machine               */
  71. int     argc;
  72. char   *argv[];
  73. {
  74.     Chan *curchan;
  75. #ifdef DEBUG
  76.     ll_log (logptr, LLOGBTR, "ch_pobox ()");
  77. #endif
  78.  
  79.     if ((curchan = ch_nm2struct (argv[0])) == (Chan *) NOTOK)
  80.     err_abrt (RP_PARM, "unknown channel name '%s'", argv[0]);
  81.                   /* find out who I am                  */
  82.  
  83.     ch_llinit (curchan);
  84.     if (rp_isbad (qu_init (argc, argv)))
  85.     return (RP_NO);          /* problem setting-up for deliver     */
  86.     if (rp_isbad (po_init ()))
  87.     return (RP_NO);
  88.  
  89.     phs_note (curchan, PHS_WRSTRT);
  90.  
  91.     if (rp_isbad (qu2po_send (argv[0])))
  92.     {                             /* send the batch of outgoing mail    */
  93.     qu_fakrply (po_state);   /* problem, but hide from Deliver     */
  94.     po_end (NOTOK);
  95.     }
  96.     else
  97.     {
  98.     po_end (OK);
  99.     phs_note (curchan, PHS_WREND);
  100.     }
  101.  
  102.     qu_end (OK);                  /* done with Deliver function         */
  103.     return (RP_OK);          /* NORMAL RETURN                      */
  104. }
  105.  
  106. /* */
  107.  
  108. /* VARARGS2 */
  109.  
  110. err_abrt (code, fmt, b, c, d)     /* terminate ourself                  */
  111. int     code;
  112. char    fmt[],
  113.         b[],
  114.         c[],
  115.         d[];
  116. {
  117. #ifdef DEBUG
  118.     char linebuf[LINESIZE];
  119. #endif
  120.  
  121.     qu_end (NOTOK);
  122.     po_end (NOTOK);
  123.     if (rp_isbad (code))
  124.     {
  125. #ifdef DEBUG
  126.     if (rp_gbval (code) == RP_BNO || logptr -> ll_level >= LLOGBTR)
  127.     {                         /* don't worry about minor stuff      */
  128.         sprintf (linebuf, "%s%s", "err [ ABEND (%s) ]\t", fmt);
  129.         ll_log (logptr, LLOGFAT, linebuf, rp_valstr (code), b, c, d);
  130.         abort ();
  131.     }
  132. #endif
  133.     }
  134.     ll_close (logptr);           /* in case of cycling, close neatly   */
  135.     exit (code);
  136. }
  137.